package cn.wildfirechat.model;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

/**
 * Created by heavyrainlee on 14/12/2017.
 */
public class UserInfo implements Parcelable, Comparable<UserInfo> {
    public String uid = "uid";
    public String name= "name";
    public String displayName= "displayName";
    public String groupAlias= "groupAlias"; // 用户在群里面给自己设置的备注，不同群不一样
    public String friendAlias= "friendAlias"; // 我为好友设置的备注
    public String portrait= "portrait";
    public int gender;
    public String mobile= "mobile";
    public String email= "email";
    public String address= "address";
    public String company= "company";
    public String social= "social";
    public String extra= "extra";
    public long updateDt;
    public int type; //0 normal; 1 robot; 2 thing;
    public int fromsource; // 好友请求来源

    public UserInfo() {
    }

    @Override
    public int compareTo(@NonNull UserInfo userInfo) {
        return displayName.compareTo(userInfo.displayName);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.uid);
        dest.writeString(this.name);
        dest.writeString(this.displayName);
        dest.writeString(this.groupAlias);
        dest.writeString(this.friendAlias);
        dest.writeString(this.portrait);
        dest.writeInt(this.gender);
        dest.writeString(this.mobile);
        dest.writeString(this.email);
        dest.writeString(this.address);
        dest.writeString(this.company);
        dest.writeString(this.social);
        dest.writeString(this.extra);
        dest.writeLong(this.updateDt);
        dest.writeInt(this.type);
        dest.writeInt(this.fromsource);
    }

    protected UserInfo(Parcel in) {
        this.uid = in.readString();
        this.name = in.readString();
        this.displayName = in.readString();
        this.groupAlias = in.readString();
        this.friendAlias = in.readString();
        this.portrait = in.readString();
        this.gender = in.readInt();
        this.mobile = in.readString();
        this.email = in.readString();
        this.address = in.readString();
        this.company = in.readString();
        this.social = in.readString();
        this.extra = in.readString();
        this.updateDt = in.readLong();
        this.type = in.readInt();
        this.fromsource = in.readInt();
    }

    public static final Creator<UserInfo> CREATOR = new Creator<UserInfo>() {
        @Override
        public UserInfo createFromParcel(Parcel source) {
            return new UserInfo(source);
        }

        @Override
        public UserInfo[] newArray(int size) {
            return new UserInfo[size];
        }
    };

    @NonNull
    @Override
    public String toString() {
        return uid + "," + displayName + "," + name + "," + mobile + "," + (gender == 0 ? "男" : "女")
                + "," + address + "," + company + "," + friendAlias + "," + groupAlias + "," + email + "," + fromsource;
    }

}
